package com.zretc.service;

import com.zretc.dao.AccountDao;
import com.zretc.domain.Account;
import jdk.nashorn.internal.runtime.UserAccessorProperty;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.Test;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

public class Test1 {
    @Test
    public void test1() throws IOException {
        //获得核心配置文件
        InputStream resourceAsStream = Resources.getResourceAsStream("sqlMapConfig.xml");
        //获得session工厂对象
        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(resourceAsStream);
        //获得session回话对象
        SqlSession sqlSession = sqlSessionFactory.openSession();

        AccountDao accountDao= sqlSession.getMapper(AccountDao.class);

        List<Account> accounts= accountDao.findAll();
        System.out.println(accounts);

    }

}
